﻿using System.Linq.Expressions;
using AutoTest.Common.UtilsHelper;

namespace AutoTest.Common.Extension
{
    /// <summary>
    /// lamda表达式
    /// </summary>
    public static class ExpressionExtension
    {
        /// <summary>
        /// AND操作
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> left,
         Expression<Func<T, bool>> right)
        {
            return ExpressionHelper.And(left, right);
        }

        /// <summary>
        /// OR操作
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> left,
         Expression<Func<T, bool>> right)
        {
            return ExpressionHelper.Or(left, right);
        }

        /// <summary>
        /// 取反操作
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expre"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> expre)
        {
            return ExpressionHelper.Not(expre);
        }
    }
}
